package com.gxa.springboot251.controller;

import com.gxa.springboot251.pojo.User;
import com.gxa.springboot251.util.JsonResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/user")
public class UserController {

    @PostMapping("/get")
    public JsonResult get(@RequestParam("id") Integer id) {
        User user = new User();
        user.setId(1);
        user.setName("王浩");
        user.setBirth(new Date());
        user.setSex("男");
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(user);
        return jsonResult;
    }

    @PostMapping("/add")
    public JsonResult getAdd(User user) {

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(user);
        return jsonResult;
    }
}
